<?php


/**
 * Description of LiveRankings
 *
 * @author De Cramer Oliver
 */

namespace ManiaLivePlugins\MLEPP\Widgets\Widgets\Controlers\Defaults\endRace_LocalRecords;

use ManiaLive\PluginHandler\PluginHandler;
use ManiaLive\Event\Dispatcher;
use ManiaLive\Data\Storage;

class Standard extends \ManiaLivePlugins\MLEPP\Widgets\Structures\TypeController {

    private $lrPlugin;

    public function onInit() {
        parent::onInit();
        $this->setVersion(0.1);
        $this->setWhenToShow(2);
		$this->setIsUnique(true);
    }

    public function  onLoad() {
        parent::onLoad();
    }

    public function  onReady() {
        parent::onReady();
        $this->lrPlugin = \ManiaLivePlugins\MLEPP\LocalRecords\LocalRecords::getInstance();
         $this->onMLEPP_LocalRecords_newChallange($this->data, array());
    }

	public function onUnload() {
		unset($this->lrPlugin);
		parent::onUnload();
	}
	
	public function onMLEPP_LocalRecords_newChallange($records, $players){
		$this->data = array();
        $this->data = $records;
		$this->resetWidgetData();
        $this->updateWidgetData($records);
    }

	public function onEndMap($rankings, $challenge, $wasWarmUp, $matchContinuesOnNextChallenge, $restartChallenge){
		$this->data = array();
        $this->data = $this->lrPlugin->getRecords();
		$this->resetWidgetData();
		$this->updateWidgetData($this->data);
        parent::onEndMap($rankings, $challenge, $wasWarmUp, $matchContinuesOnNextChallenge, $restartChallenge);
    }
	
	function destroy()
	{
		parent::destroy();
		gc_collect_cycles();
	}
}
?>
